import { Component, Input, ViewChild, ElementRef, AfterViewInit } from '@angular/core';  
import { NavController, NavParams } from 'ionic-angular';
import { Plan } from '../plan/plan'
import { HabitService } from '../../service/habit.service';
//import Dygraph from 'dygraphs';

@Component ({  
    selector: 'my-dygraph2',  
    template:`  
        
  
            <div #graph2 style="height: 20px;   width: 100%;"></div>  
          
    `  
})  
export class DygraphComponent2  implements  AfterViewInit  {  
  
wave_height = 335;  
  
  constructor() {  
      console.log("the height: "+ screen.height);  
  
  }  
  
  
  
  @ViewChild('graph2')  
  elt:ElementRef;  
  
  @Input()  
  title:string;  
  
  ngAfterViewInit() {  
    this.wave_height = (screen.height /10) *7 - 9 - 35;  
    this.elt.nativeElement.style.height=this.wave_height+"px";  
 console.log("calc height: "+ this.wave_height);  
   
 var data = [];  
      var t = new Date();  
      for (var i = 10; i >= 0; i--) {  
        var x = new Date(t.getTime() - i * 1000);  
        data.push([x, Math.random() , Math.random()]);  
      }  
  
  /*  var g = new Dygraph(this.elt.nativeElement, data,  
              {  
                labels: [ "x", "Current" ,"Set"],  
                 
                   colors: ["rgb(255,0,0)",  
                   "rgb(0,255,0)",  
                        ],  
                
              title: '柱箱温度',  
                ylabel: '温度(℃)',  
                axisLineColor: 'white',  
                axisLineWidth: 3.9,  
                  
                  strokeWidth: 3.0,  
                    drawPoints: true,  
                    pointSize: 4,  
                    highlightCircleSize: 6,  
                    titleHeight: 25,  
  
                     legend: 'always',  
                     labelsSeparateLines:true,  
                      
              });  
              */
  
             // window.onresize();  
             
    /*  
      setInterval(function() {  
        var x = new Date();  // current time  
        var y = Math.random();  
        data.push([x, y]);  
        g.updateOptions({'file':data});  
       }, 1000); */  
  }  
  
  
}  